<?php if (!defined('THINK_PATH')) exit();?><style type="text/css">
    .update_tb tr {
        height: 30px;
    }


    #zpyl label {
        display: inline-block;
        width: 70px;
        padding: 5px 0 5px 10px;
    }

    #zpyl div {

        padding: 5px 0 5px 0px;
    }
    .picshow{
        width: 200px;
        border: 2px solid #bfc2c5;
        border-radius: 5px;
    }
    .picinfo{
        font-size: 14px;
    }
    .info_title{
        font-weight: bold;
    }
    li{
        list-style-type:none;
    }
    .picdown{
        background: url('Public/js/jquery-easyui-1.7.0/themes/icons/icon-standard/16x16/bullet-picture.png') no-repeat;
        text-decoration:none;
    }
</style>

<table id="mywallhavenpic-dg"></table>


<div id="mytool-pic">
    <table>
        <tr>
            <td >
                <input id="general_categories" type="checkbox" name="categories" value="1" checked="checked" />普通
                <input id="anime_categories" type="checkbox" name="categories" value="1" checked="checked" />漫画
                <input id="people_categories" type="checkbox" name="categories" value="1" checked="checked" />人物
            </td>
            <td >
                <input id="sfw_categories" type="checkbox" name="categories" value="1"  checked="checked"/>sfw
                <input id="sketchy_categories" type="checkbox" name="categories" value="1"/>sketchy
                <input id="nsfw_categories" type="checkbox" name="categories" value="1"/>nsfw
            </td>
            <td >
                <input id="search_q"  class="easyui-textbox" data-options="prompt:''" style="width:100px">
                <a href="#" class="easyui-linkbutton" onclick="search_haven1()"
                   data-options="iconCls:'icon-search',plain:'true'">搜索</a>
            </td>



            <!--<td>-->
                <!--<a href="#" class="easyui-linkbutton"  onclick="downloadss()" data-options="iconCls:'icon-standard-folder-picture',plain:'true'">下载</a>-->
            <!--</td>-->
        </tr>
    </table>



</div>
<!--工具栏 -->

<script type="text/javascript">




    $('#mywallhavenpic-dg').datagrid({
        url : '/wallhaven/index.php/Home/Wallhaven/read',
        toolbar: '#mytool-pic',
        pagination: true,
        fit: true,
        width: function () {
            return document.body.clientWidth * 0.9
        },
        nowrap: false,//
        collapsible: true,
        fitColumns: true,
        autoRowHeight: true,
        striped: true,//交替行
        singleSelect: false,//只允许选择一行
        rownumbers: true,
        border: false,
        sortName: 'id',
        sortOrder: 'desc',//倒序排列
        remoteSort: true,
        pageSize: 100,
        method: "post",
        pageList: [100, 200, 500],
        columns: [[
            {
                field: 'id',
                checkbox: true
            }, {
                field: 'url',
                hidden:true

            }, {
                field: 'short_url',
                hidden:true

            }
            , {
                field: 'purity',
                hidden:true

            }, {
                field: 'category',
                hidden:true

            }, {
                field: 'dimension_x',
                hidden:true

            }, {
                field: 'dimension_y',
                hidden:true

            }, {
                field: 'resolution',
                hidden:true

            }, {
                field: 'ratio',
                hidden:true

            }, {
                field: 'ratio',
                hidden:true

            }, {
                field: 'file_type',
                hidden:true

            }, {
                field: 'colors',
                hidden:true

            }, {
                field: 'path',
                hidden:true

            }, {
                field: 'colors',
                hidden:true

            }, {
                field: 'created_at',
                hidden:true

            }, {
                field: 'localpath',
                hidden:true

            }, {
                field: 'createtime',
                title: '下载日期',
                hidden:true
            }

            , {
                field: 'thumbs',
                title: '图片',
                width: 400,
                align: 'center',
                formatter: function (value, row, index) {
                    if (value != '' && value != null) {
                        var data = eval('(' + value + ')');



                        var color=eval('(' + row.colors + ')');
                        // console.log(color)
                        var colorstr="";

                        for(var i=0;i<color.length;i++){
                            colorstr=colorstr+'<div style="text-align:center;border: 1px solid #868181;width: 100px;margin-right: 5px;display: inline-block;border-radius: 5px;background-color:'+color[i]+'">'+color[i]+'</div>'
                        }



                        var str=`
						<table width="98%"  border="0" cellspacing="0">
  <tr>
    <td style="text-align:center"><a href="/wallhaven/Public/${row.localpath}" target="_blank"><img src="/wallhaven/Public/${row.localsmallpath}" alt="" class="picshow"></a></td>
	<td>
	<ul class="picinfo">
		<li><span class="info_title">url:</span>${row.url}<a href="${row.url}" target="_blank" class="picdown">&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
		<li><span class="info_title">short_url:</span>${row.short_url}<a href="${row.short_url}" target="_blank" class="picdown">&nbsp;&nbsp;&nbsp;&nbsp;</a></li>
		<li><span class="info_title">views:</span>${row.views}</li>
		<li><span class="info_title">favorites:</span>${row.favorites}</li>
		<li><span class="info_title">purity:</span>${row.purity}</li>
		<li><span class="info_title">category:</span>${row.category}</li>
		<li><span class="info_title">dimension:</span>${row.dimension_x}:</span>${row.dimension_y}</li>
		<li><span class="info_title">resolution:</span>${row.resolution}</li>
		<li><span class="info_title">ratio:</span>${row.ratio}</li>
		<li><span class="info_title">file_size:</span>${row.file_size}</li>
		<li><span class="info_title">file_type:</span>${row.file_type}</li>
		<li><span class="info_title">colors:</span>${colorstr}</li>
	</ul>
	</td>
  </tr>
</table>
						`;
                        return str;
                    }
                }

            }


        ]],

        onLoadSuccess: function (data) {
            $('#mywallhavenpic-dg').datagrid('fixRowHeight'); //格式化后行号对齐
        },


        onDblClickRow: function (rowIndex, rowData) {


        },
        onSelect: function (index, row) {



        },
        rowStyler: function (index, row) {

        }
    });
    // 显示导入窗口
    function show_add_mes() {
        $('#add_mes').window('open');
    }



    // 刷新
    function reloadmes() {
        $('#mywallhavenpic-dg').datagrid('reload', {
            jhh: '',
            jhlx: 'zpjh'
        });
    }
    // 搜索
    function search_haven1() {

        var purity =new Array();
        var category=new Array();

        var general_categories= $("#general_categories").is(':checked');
        var anime_categories= $("#anime_categories").is(':checked');
        var people_categories= $("#people_categories").is(':checked');


        if(general_categories==true){
            category.push('general')
        }

        if(anime_categories==true){
            category.push('anime')
        }
        if(people_categories==true){
            category.push('people')
        }


        var sfw_categories= $("#sfw_categories").is(':checked');
        var sketchy_categories= $("#sketchy_categories").is(':checked');
        var nsfw_categories= $("#nsfw_categories").is(':checked');



        if(sfw_categories==true){
            purity.push('sfw')
        }
        if(sketchy_categories==true){
            purity.push('sketchy')
        }
        if(nsfw_categories==true){
            purity.push('nsfw')
        }



        var picinfo=$("#search_q").textbox("getText")

        $('#mywallhavenpic-dg').datagrid("load",{
            purity:purity,
            category:category,
            picinfo:picinfo
        });

    }




    function showhbxx2() {
        var row = $('#mywallhavenpic-dg').datagrid("getSelected");


    }
</script>